Skip to content

Fix task worktree lifecycle and stale context cleanup#72

Merged
krandder merged 2 commits into
mainfrom
codex/worktree-cleanup
Mar 18, 2026
Merged

Fix task worktree lifecycle and stale context cleanup#72
krandder merged 2 commits into
mainfrom
codex/worktree-cleanup

Conversation

@krandder

Copy link
Copy Markdown
Contributor

Summary

  • refresh .task metadata server-side when a claim provisions or reuses task worktrees
  • reinitialize clean mismatched worktrees instead of silently reusing stale branch/context state
  • clean up closed task worktrees in the HTTP lifecycle and daemon sweep, and add a stale-worktree audit/cleanup script

Live cleanup

  • audited /tmp/taskcore-worktrees before apply: 126 total, 58 stale, 1 mismatched .task, 36 broken .task
  • ran node --import tsx scripts/cleanup-stale-worktrees.ts --apply --json
  • post-apply audit: 68 active worktrees remain, 0 stale, 0 mismatched .task, 0 broken .task

Verification

  • npx tsx --test --test-concurrency=1 middle/test/worktree.test.ts middle/test/http.test.ts
  • node --import tsx scripts/cleanup-stale-worktrees.ts --json
  • node --import tsx scripts/cleanup-stale-worktrees.ts --apply --json
  • node --import tsx scripts/cleanup-stale-worktrees.ts --json

@krandder krandder merged commit ba51d2d into main Mar 18, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant